package com.sdp.wx.flow;

import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.sdp.core.bizc.utils.ApplicationContextUtils;
import com.sdp.wx.db.wx_assets_report.entity.WxAssetsReport;
import com.sdp.wx.db.wx_assets_report.service.IWxAssetsReportService;
import com.sdp.wx.utils.WxConstants;

public class AssetsReportEndNodeTaskListener implements TaskListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	@Override
	public void notify(DelegateTask delegateTask) {
		String isPass = (String) delegateTask.getVariable("isPass");
		WxAssetsReport report = (WxAssetsReport) delegateTask.getVariable("flowData");
		if (!StringUtils.isEmpty(isPass) && WxConstants.是.getCode().equals(isPass)
				&& report != null) {
			
			IWxAssetsReportService assetsReportService = ApplicationContextUtils.getBean(IWxAssetsReportService.class);
			UpdateWrapper<WxAssetsReport> updateWrapper = new UpdateWrapper<>();
			updateWrapper.lambda().eq(WxAssetsReport::getKeyId, report.getKeyId())
				.set(WxAssetsReport::getReportStatus, WxConstants.流程审批状态_审批通过.getCode());
			assetsReportService.update(updateWrapper);
		}

	}

}
